﻿<Window x:Class="SnelsteRoute.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:SnelsteRoute"
        Title="MainWindow" Height="600" Width="800" x:Name="MainWindowRef" Closed="MainWindowRef_Closed" Activated="MainWindowRef_Activated">

    <Window.Resources>
        <ObjectDataProvider x:Key="Models" ObjectType="{x:Type local:Models}" MethodName="GetInstance" />
        <Image x:Key="exchangeImg" Source="/img/exchange.png"/>
    </Window.Resources>
    <Border Padding="8">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="18" />
                <RowDefinition Height="60" />
                <RowDefinition Height="18" />
                <RowDefinition Height="60"/>
                <RowDefinition Height="5"/>
                <RowDefinition />
                <RowDefinition Height="18"/>
                <RowDefinition Height="18"/>
            </Grid.RowDefinitions>
        
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="52" />
                <ColumnDefinition/>
                <ColumnDefinition Width="60" />
                <ColumnDefinition Width="60" />
            </Grid.ColumnDefinitions>
            
            <Label Content="Select a configuration"  Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3"/>
            <ComboBox ItemsSource="{Binding Configurations,Source={StaticResource Models}}" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="10" SelectionChanged="ComboBox_SelectionChanged">
                <ComboBox.Resources>
                    <DataTemplate DataType="{x:Type local:Configuration}">
                        <TextBlock Text="{Binding Description}" />
                    </DataTemplate>
                </ComboBox.Resources>
            </ComboBox>
            
            
            <Label Content="From" Grid.Row="2" Grid.Column="0" />
            <Label Content="To" Grid.Row="2" Grid.Column="2" />
            <Label Content="# squares" Grid.Row="2" Grid.Column="3" />

            <ComboBox ItemsSource="{Binding ElementName=MainWindowRef, Path=SelectedConfiguration.Aspects}" Grid.Row="3" Grid.Column="0" Name="FromAspect">
                <ComboBox.Resources>
                    <DataTemplate DataType="{x:Type local:Aspect}">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="{Binding ImageUri}" />
                            <TextBlock Text="{Binding Name}" Padding="10,0,0,0" VerticalAlignment="Stretch" TextAlignment="Center"/>
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.Resources>
            </ComboBox>
            
            <Button Name="swapBtn" Click="swapBtn_Click" Grid.Row="3" Grid.Column="1" Content="{StaticResource exchangeImg}" />

            <ComboBox ItemsSource="{Binding ElementName=MainWindowRef, Path=SelectedConfiguration.Aspects}" Grid.Row="3" Grid.Column="2" Name="ToAspect">
                <ComboBox.Resources>
                    <DataTemplate DataType="{x:Type local:Aspect}">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="{Binding ImageUri}" />
                            <TextBlock Text="{Binding Name}" Padding="10,0,0,0" VerticalAlignment="Stretch" TextAlignment="Center"/>
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.Resources>
            </ComboBox>
            
            <ComboBox Name="desiredHops" Grid.Row="3" Grid.Column="3" />            

            <Button Content="Go" Click="Button_Click" Grid.Row="3" Grid.Column="4"  />
            
            <TextBlock Name="placeholderOutput" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="100" />

            <ScrollViewer  Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="10">
                <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal">
                        <Label Content="Cost" Width="45"/>
                        <Label Content="Solutions:"></Label>
                    </StackPanel>
                
                    <ItemsControl ItemsSource="{Binding ElementName=MainWindowRef, Path=FoundRoutes}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Vertical" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.Resources>
                            <DataTemplate DataType="{x:Type local:Route}">
                                <StackPanel Orientation="Horizontal">
                                
                                    <Border BorderBrush="DarkGray" BorderThickness="1" VerticalAlignment="Stretch" Width="40" Margin="0,0,5,0">
                                        <Label Content="{Binding Path=Cost}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                    </Border>
                                    <ItemsControl ItemsSource="{Binding Path=Hops}"  >
                                        <ItemsControl.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch"   />
                                            </ItemsPanelTemplate>                                
                                        </ItemsControl.ItemsPanel>
                                        <ItemsControl.Resources>
                                            <DataTemplate DataType="{x:Type local:Aspect}">
                                                <StackPanel Orientation="Vertical" Width="70">
                                                    <Label Content="{Binding Path=Name}"/>
                                                    <Image Source="{Binding Path=ImageUri}" />
                                                </StackPanel>
                                            </DataTemplate>
                                        </ItemsControl.Resources>
                                    </ItemsControl>
                                </StackPanel>
                            </DataTemplate>
                        </ItemsControl.Resources>
                    </ItemsControl>
                </StackPanel>
            </ScrollViewer>


            <Label Name="errorMessages" Grid.Row="6" Grid.ColumnSpan="100"  Foreground="Red" />
            <Label Name="statistics" Grid.Row="7" Grid.ColumnSpan="100" Foreground="DarkSlateBlue" />
        </Grid>
    </Border>
</Window>
